package com.famid.flashcards.util;

import java.util.List;
import java.util.Random;

import com.famid.flashcards.data.Card;

public class ShuffleCards {
	
	public static void shuffle(List<Card> list) {
		int size = list.size();
		Random random = new Random();
		random.nextInt();
		for (int i = 0; i < size; i++) {
			int change = i + random.nextInt(size - i);
			swap(list, i, change);
		}
	}
	
	private static void swap(List<Card> list, int original, int destination) {
		Card helper = list.get(original);
		list.set(original, list.get(destination));
		list.set(destination, helper);
	}

}
